home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
mint
/
lib
/
mntlib44.zoo
/
mntlib
/
mkdir.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-10-12
|
946b
|
50 lines
/* mkdir: make a new directory
* written by Eric R. Smith and placed in the public domain
* modified by Alan Hourihane, to check for directory and return EEXIST.
*/
#include <errno.h>
#include <limits.h>
#include <osbind.h>
#include <mintbind.h>
#include <types.h>
#include <stat.h>
#include <unistd.h>
#include "lib.h"
extern int errno;
extern int __mint;
int mkdir(_path, mode)
const char *_path;
mode_t mode;
{
struct stat statbuf;
int rv;
char path[PATH_MAX];
_unx2dos(_path, path);
rv = stat(path, &statbuf); /* Stat directory */
if (rv == 0) { /* Does it exist ? */
errno = EEXIST; /* Yes, so tell user. */
return -1;
}
if (errno != ENOENT) { /* Return stat error, if other than */
return -1; /* File not found. */
}
rv = Dcreate(path);
if (rv < 0) {
errno = -rv;
return -1;
}
if (__mint >= 9) {
int umask = Pumask (0);
(void) Pumask (umask);
(void)Fchmod(path, mode & ~umask);
}
return 0;
}